<?php
/**
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/5/28
 * Time: 19:33
 */

namespace Biz\model\smallenergy;

class SmallEnergyUser extends \Doraemon\pockets\datebase\BaseDbModel
{
    const _CONFIG_FILE_ = 'db_im';

    const _CONFIG_SELECT_ = 'db_im';

    const _DATABASE_ = 'hhz_im';

    const _TABLE_NAME = 'hhz_smallenergy_user';

    const STATUS_NORMAL = 1;
    const STATUS_DELETE = 9;

    public static function getByUid($uid)
    {
        return self::get('*', [
            'uid' => $uid,
            'status' => self::STATUS_NORMAL
        ]);
    }

    public static function addUser($uid, $smallEnergyId)
    {
        return self::insert([
            'uid' => $uid,
            'uuid' => $smallEnergyId,
            'addtime' => date('Y-m-d H:i:s'),
            'status' => self::STATUS_NORMAL
        ])->rowcount();
    }

    public static function getUserInfoByUuid($uuid, $field = '*')
    {
        return self::get($field, [
            'uuid' => $uuid
        ]);
    }

    public static function updateByUid($uid, $uuid)
    {
        self::update(['uuid' => $uuid], ['uid' => $uid])->rowCount();
    }
}